package numWaterBottles;

public class Solution {
    public int numWaterBottles(int numBottles, int numExchange) {
        int count=0;
        int rest=0;//没换的空瓶子
        while(rest>0){
            count+=numBottles;
            rest=numBottles+rest;//喝完了，剩下的空水瓶子
            numBottles=rest/numExchange; //剩下的水平可以换多少水
            rest%=numExchange; //换了之后还剩下多少空水瓶
        }
        return count;
    }
}
